package com.tocean.app.service.framework;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tocean.app.controller.framework.request.RanksSaveRequest;
import com.tocean.app.entity.framework.Ranks;
import com.tocean.app.mapper.framework.RanksMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
public class RanksService {
    @Autowired
    private RanksMapper mapper;

    public void save(RanksSaveRequest request) {
        Ranks _entity = new Ranks();
        _entity.setName(request.getName());
        _entity.setScore(request.getScore());
        mapper.insert(_entity);
    }

    public List<Ranks> ranksList() {
        return mapper.selectList(new LambdaQueryWrapper<Ranks>()
                .eq(Ranks::getIsDel, Boolean.FALSE)
                .orderByDesc(Ranks::getScore).last("limit 10"));
    }





}
